package com.hqq.mediator;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

/**
 * PartyImpl
 * Created by heqianqian on 2017/6/22.
 */
public class PartyImpl implements Party {

    private static final Logger LOGGER = LoggerFactory.getLogger(PartyImpl.class);

    private List<PartyMember> partyMemberList = new ArrayList<>();

    @Override
    public void addMember(PartyMember partyMember) {
        partyMemberList.add(partyMember);
        partyMember.joinParty(this);
    }

    @Override
    public void act(PartyMember partyMember, Action action) {
        for (PartyMember pm : partyMemberList) {
            if (!pm.equals(partyMember)) {
                pm.partyAction(action);
            }
        }
    }
}
